#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#声明一个Dict
dict={'google':'www.google.hk.com','baidu':'www.baidu.com'}

#get one entity of dict
print(dict['google'])
#update one entity of dict
dict['google']='www.google.sg.com' #dict.update()
print(dict)
#add one enttiy to dict
dict['taobao']='www.taobao.com'
#dict.setdefault() 但如果键不存在于字典中，将会添加键并将值设为default
print(dict)
#del one entity from dict
del dict['baidu']
print(dict)
#set the default value when could not find the entity from dict
print('default1=',dict.get('alibaba'))
print('default2=',dict.get('alibaba','www.alibaba'))#不对集合做操作
print(dict)

#inner func
print(len(dict))
print(str(dict))
print("-------loop all key value-------------")
for k,v in dict.items():
    print("key:"+k+",value:"+v)
for v in  dict.values():
    print('allvalue:'+v)
for key in  dict.keys():
    print('allkey:'+key)

print("-------loop all key value-------------")

